import system from '@/router/modules/system' // 系统路由
import whitePage from '@/router/modules/whitePage' // 白名单路由（不需要登录）

export default function useDefaultRoute() {
  // 默认路由
  const defaultRoutes = [...system, ...whitePage]

  // 默认路由的name数组
  const defaultRouteNames = []
  const addDefaultRoutName = function (arrRoutes) {
    arrRoutes.forEach((r) => {
      if (r.name) {
        defaultRouteNames.push(r.name)
      }
      if (r.children && r.children.length > 0) {
        addDefaultRoutName(r.children)
      }
    })
  }
  addDefaultRoutName(defaultRoutes) //递归遍历

  // 判断跳转的路由是否是默认路由
  const ifDefaultRoute = function (r) {
    return defaultRouteNames.includes(r.name)
  }

  return { defaultRoutes, defaultRouteNames, ifDefaultRoute }
}
